package com.kexilo.core.common.config.properties;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 系统配置属性
 *
 * @author Kexilo
 */
@Component
@ConfigurationProperties(prefix = "kexilo.system")
public class SystemProperties {
    
    private String name = "Kexilo管理系统";
    private String version = "1.0.0";
    private String description = "基于Spring Boot的企业级管理系统";
    private String copyrightYear = "2024";
    private String author = "Kexilo";
    
    private FileProperties file = new FileProperties();
    private CacheProperties cache = new CacheProperties();
    private LogProperties log = new LogProperties();
    
    /**
     * 文件配置
     */
    public static class FileProperties {
        /** 文件上传路径 */
        private String uploadPath = "/uploads";
        
        /** 文件访问路径 */
        private String accessPath = "/files";
        
        /** 允许的文件扩展名 */
        private String[] allowedExtensions = {"jpg", "jpeg", "png", "gif", "pdf", "doc", "docx", "xls", "xlsx"};
        
        /** 最大文件大小（MB） */
        private int maxSize = 10;
        
        /** 头像上传路径 */
        private String avatarPath = "/avatar";
        
        /** 头像最大大小（MB） */
        private int avatarMaxSize = 2;

        // Getter and Setter methods
        public String getUploadPath() {
            return uploadPath;
        }

        public void setUploadPath(String uploadPath) {
            this.uploadPath = uploadPath;
        }

        public String getAccessPath() {
            return accessPath;
        }

        public void setAccessPath(String accessPath) {
            this.accessPath = accessPath;
        }

        public String[] getAllowedExtensions() {
            return allowedExtensions;
        }

        public void setAllowedExtensions(String[] allowedExtensions) {
            this.allowedExtensions = allowedExtensions;
        }

        public int getMaxSize() {
            return maxSize;
        }

        public void setMaxSize(int maxSize) {
            this.maxSize = maxSize;
        }

        public String getAvatarPath() {
            return avatarPath;
        }

        public void setAvatarPath(String avatarPath) {
            this.avatarPath = avatarPath;
        }

        public int getAvatarMaxSize() {
            return avatarMaxSize;
        }

        public void setAvatarMaxSize(int avatarMaxSize) {
            this.avatarMaxSize = avatarMaxSize;
        }
    }
    
    /**
     * 缓存配置
     */
    public static class CacheProperties {
        /** 缓存名称 */
        private String[] names = {"user", "role", "menu", "dict", "config"};
        
        /** 默认过期时间（分钟） */
        private int defaultExpireTime = 60;
        
        /** 用户缓存过期时间（分钟） */
        private int userExpireTime = 30;
        
        /** 字典缓存过期时间（分钟） */
        private int dictExpireTime = 120;
        
        /** 是否启用本地缓存 */
        private boolean enableLocalCache = true;

        // Getter and Setter methods
        public String[] getNames() {
            return names;
        }

        public void setNames(String[] names) {
            this.names = names;
        }

        public int getDefaultExpireTime() {
            return defaultExpireTime;
        }

        public void setDefaultExpireTime(int defaultExpireTime) {
            this.defaultExpireTime = defaultExpireTime;
        }

        public int getUserExpireTime() {
            return userExpireTime;
        }

        public void setUserExpireTime(int userExpireTime) {
            this.userExpireTime = userExpireTime;
        }

        public int getDictExpireTime() {
            return dictExpireTime;
        }

        public void setDictExpireTime(int dictExpireTime) {
            this.dictExpireTime = dictExpireTime;
        }

        public boolean isEnableLocalCache() {
            return enableLocalCache;
        }

        public void setEnableLocalCache(boolean enableLocalCache) {
            this.enableLocalCache = enableLocalCache;
        }
    }
    
    /**
     * 日志配置
     */
    public static class LogProperties {
        /** 是否启用操作日志 */
        private boolean enableOperationLog = true;
        
        /** 是否启用登录日志 */
        private boolean enableLoginLog = true;
        
        /** 日志保留天数 */
        private int retentionDays = 30;
        
        /** 是否异步保存日志 */
        private boolean async = true;
        
        /** 异步队列大小 */
        private int asyncQueueSize = 1000;

        // Getter and Setter methods
        public boolean isEnableOperationLog() {
            return enableOperationLog;
        }

        public void setEnableOperationLog(boolean enableOperationLog) {
            this.enableOperationLog = enableOperationLog;
        }

        public boolean isEnableLoginLog() {
            return enableLoginLog;
        }

        public void setEnableLoginLog(boolean enableLoginLog) {
            this.enableLoginLog = enableLoginLog;
        }

        public int getRetentionDays() {
            return retentionDays;
        }

        public void setRetentionDays(int retentionDays) {
            this.retentionDays = retentionDays;
        }

        public boolean isAsync() {
            return async;
        }

        public void setAsync(boolean async) {
            this.async = async;
        }

        public int getAsyncQueueSize() {
            return asyncQueueSize;
        }

        public void setAsyncQueueSize(int asyncQueueSize) {
            this.asyncQueueSize = asyncQueueSize;
        }
    }

    // Main class getter and setter methods
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getCopyrightYear() {
        return copyrightYear;
    }

    public void setCopyrightYear(String copyrightYear) {
        this.copyrightYear = copyrightYear;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public FileProperties getFile() {
        return file;
    }

    public void setFile(FileProperties file) {
        this.file = file;
    }

    public CacheProperties getCache() {
        return cache;
    }

    public void setCache(CacheProperties cache) {
        this.cache = cache;
    }

    public LogProperties getLog() {
        return log;
    }

    public void setLog(LogProperties log) {
        this.log = log;
    }
}
